<template>
  <!-- 登录写在这里 -->
  <!-- <img width="100%" src="../../assets/logo.png" alt=""> -->
  <div class="login_body">
    <div class="login_body_bgcolor">
      <h1 class="login_body_title">荔枝营销推广系统 ( AI智能客服版 )</h1>
    </div>
    <div class="login_body_main">
      <img class="logo_img" src="../../assets/logo.png" alt />
      <div class="login_body_main-control">
        <div>
          <label for="username">账号</label>
          <input id="username" type="text" placeholder="请输入手机号" v-model="phonenumber" />
        </div>
        <div>
          <label for="password">密码</label>
          <input id="password" type="password" placeholder="请输入密码" v-model="password" />
        </div>
        <div>
          <label for="password_2">密码</label>
          <input id="password_2" type="password" placeholder="再输一次密码" v-model="password_2" />
        </div>
        <div>
          <button @click="reg">注 册</button>
          <button @click="$router.push({ name: 'Login' })">登 录</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      phonenumber: null,
      password: null,
      password_2: null
    }
  },
  methods: {
    reg() {
      if (this.phonenumber == null || this.password == null || this.password_2 == null) {
        this.$msgBox.show("请输入完整", "tip", 300, 60);
        return;
      }
      if (this.password_2 !== this.password) {
        this.$msgBox.show("两次输入的密码不一致", "tip", 300, 60);
        return;
      }
      this.$axios.get("/api/register", {
        params: {
          name: this.phonenumber,
          phone: this.phonenumber,
          password: this.$md5.MD5_Encrypt(this.password)
        }
      }).then(({ data }) => {
        if (parseInt(data.code) === 200) {
          this.$msgBox.show("注册成功", "success", 250, 60);
          this.$cookie.setCookie("login", 1);
          this.$cookie.setCookie("name", data.data.nickName);
          this.$cookie.setCookie("expertBool", data.data.userType);
          this.$cookie.setCookie("phone", data.data.phone);
          this.$cookie.setCookie("id", data.data.id);
          this.$router.push({ name: "Home" });
        } else {
          this.$msgBox.show(data.data.msg, "error", 250, 60);
        }
      }).catch(error => {
        this.$msgBox.show("与服务器通信异常", "error", 250, 60);
      })
    }
  }
}
</script>

<style>
* {
  margin: 0px;
  padding: 0px;
}
.login_body {
  height: 100vh;
  width: 100vw;
}
.login_body_bgcolor {
  width: 100vw;
  background-color: #167a169a;
  height: 50vh;
}
.login_body_title {
  display: block;
  text-align: center;
  color: #fff;
  position: relative;
  top: 25%;
}
.login_body_main {
  height: 300px;
  max-width: 500px;
  background-color: #fff;
  border: 1px solid #e0e0e0;
  margin: 0 auto;
  position: relative;
  top: -125px;
  border-radius: 5px;
}
/* .login_body_main img {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  padding: 10px;
  background: #3d558a;
  margin: auto;
  position: absolute;
  left: 0;
  right: 0;
  top: -60px;
} */
.logo_img{
  width: 150px;
  height: 150px;
  margin: auto;
  position: absolute;
  left: 0;
  right: 0;
  top: -70px;
}
.login_body_main-control {
  border-top: 1px solid #e0e0e0;
  position: relative;
  top: 80px;
  height: calc(100% - 80px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.login_body_main-control > div {
  margin: 5px 0;
  display: flex;
}
.login_body_main-control > div label {
  position: relative;
  top: 10px;
  margin-right: 5px;
  font-size: 13px;
}
.login_body_main-control > div input {
  border: 1px solid #e0e0e0;
  outline-color: skyblue;
  border-radius: 5px;
  box-sizing: border-box;
  padding: 10px;
  width: 300px;
}
.login_body_main-control > div button {
  width: 80px;
  margin-right: 10px;
  /* flex:1; */
  color: #fff;
  background-color: #6284ff;
  border: 1px solid #6284ff;
  padding: 5px 10px;
  border-radius: 5px;
  font-weight: bold;
}
@media screen and (max-width: 500px) {
  .login_body_main {
    margin: 10px !important;
    padding: 10px;
    box-sizing: border-box;
  }
  .login_body_main-control > div label {
    display: none;
  }
}
/* .main{
        width:100%;
        height: 100vh;
    }
    .middle{
        position: absolute;
        padding: 20px;
        max-width: 700px;
        height: 230px;
        border-radius: 7px 7px;
        top: 70px;
        right: 0px;
        left: 0px;
        bottom: 0px;
        margin: auto;
        background:#f1f6f9;
    }
    .top{
        width: 100%;
        height: 50%;
        background: #b8cbff;
    }
    .top ul{
        float: right;
        list-style: none;
        padding: 50px;
        font-size: 30px;
        font-weight: bold;
        color: #fff;
    }
    .footer{
        width: 100%;
        height: 50%;
        background: #fff;
    }
    .img-box{
        position: absolute;
        top:-100px;
        left:50%;
        border-radius: 50%;
        margin: auto;
        transform: translateX(-50%);
        width: 110px;
        height: 110px;
        background:#3d558a;
        margin-bottom: -25px;
    }
    .text{
        display: flex;
        height: 100%;
    }
    .left{
        flex: 1;
        display: flex;
        background: #fff;
        justify-content: center;
        align-items: center;
    }
    .right{
        height: 100%;
    }
    .el-form{
        width: 100%;
        margin-right: 70px;
    }
    .el-button .el-form-item__content{
        margin: 0!important;
    }
    .el-form-item{
        margin-bottom: 10px;
    }
    .el-input{
        width: 100%;
    }
    .right ul{
        list-style: none;
    }
    .right ul li{
        padding: 7px;
        font-family: "黑体";
    } */
</style>
